//package org.example.cet.demos.config;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.apache.ibatis.type.TypeHandler;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import javax.sql.DataSource;
//import org.example.cet.demos.typehandler.StringArrayTypeHandler;
//
//@Configuration
//@MapperScan("org.example.cet.demos.mapper")
//public class MyBatisConfig {
//
//    @Bean
//    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
//        SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
//        sessionFactory.setDataSource(dataSource);
//        // 创建 StringArrayTypeHandler 实例并传递给 setTypeHandlers 方法
//        TypeHandler<?>[] typeHandlers = new TypeHandler<?>[]{new StringArrayTypeHandler()};
//        sessionFactory.setTypeHandlers(typeHandlers);
//        sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml"));
//        return sessionFactory.getObject();
//    }
//}